Pr epic issue 58#71
Merged
Merged
Conversation
Introduce Claude Code automation for the PetSphere repo under .claude. Adds a README, settings.json (hooks, protected paths, and MCP servers), a code-reviewer agent, and three user-invocable skills: flutter-new-component, migration-helper, and test-writer. These provide scaffolding for Flutter components, feature layer generation, and test generation, plus automatic format/lint hooks and repository-specific protections to streamline development and reviews.
…hema, tests) FIXES #27: Fix compile-time error in FeedRepository.updatePost payload construction - Replace invalid map entry syntax with proper conditional keys - Only include optional fields when non-null and non-empty - flutter analyze now passes without errors FIXES #28: Auth: Make profile upsert on signup fatal - Profile creation failures now block signup completion - User-friendly error message displayed on failure - Auth cleanup (signOut) called if profile creation fails FIXES #38: Routing hardening - validate path/query params - Create safe_route_params.dart with helpers for parameter extraction - InvalidRouteErrorScreen for missing parameters - Apply safe extraction to all 9 routes with path parameters - Prevent crashes from malformed deep links FIXES #31: Version-control Supabase schema with migrations - Add supabase/config.toml for CLI configuration - Create supabase/.env.local.example template - Add comprehensive MIGRATIONS.md workflow guide - Add supabase/README.md for setup and common operations - Add .gitignore for local env files and secrets - Schema now fully reproducible from git migrations/ FIXES #30: Testing foundation - unit tests for models - Add PetModel tests: JSON roundtrip, copyWith, null handling - Add UserModel tests: JSON serialization, copyWith - Create TEST_GUIDE.md with testing best practices - Add GitHub Actions workflow for CI (test-and-build.yml) - Runs flutter analyze and flutter test - Builds Android APK and iOS app - Validates schema migrations - Uploads coverage to Codecov Test Coverage Baseline: ✅ PetModel: 8 tests (JSON parsing, serialization, copyWith) ✅ UserModel: 5 tests (JSON parsing, serialization, copyWith) ✅ All tests passing with 0 failures CI/CD Pipeline: ✅ Tests run on push to main/develop/feature branches ✅ Tests run on PRs to main/develop ✅ Build validation for Android and iOS ✅ Schema migrations validation ✅ Coverage reporting to Codecov Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Introduce offline support and health improvements: adds OfflineCache (SharedPreferences-backed cache, TTLs, sync queue), ConnectivityService (status stream, test toggles), Riverpod connectivity providers, and offline repository wrappers for feed, marketplace, and health (cache-first reads, queued writes, TTLs). Also includes health utilities (dose scheduling, reminders, metrics), docs (OFFLINE_SUPPORT.md, IMPLEMENTATION_STATUS.md), and basic controller tests (auth, cart). .claude settings updated with Supabase plugin commands. Notes: queue format and TTL strategy implemented; sync trigger on connectivity restoration is scaffolded (TODO: wire actual sync trigger/integration).
…ntain permissions' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
GitHub deprecated actions/upload-artifact v3 on 2024-04-16. This commit updates the workflow to use v4, which fixes the failing CI job. Changes: - Update Archive coverage reports to use actions/upload-artifact@v4 - Update Archive APK to use actions/upload-artifact@v4 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR bundles Epic #58 “foundation” work across developer tooling, CI/testing, offline-first infrastructure, Supabase workflow docs, and safer routing/auth behaviors for the PetSphere Flutter app.
Changes:
- Adds Claude Code configuration (hooks, protected files), project-specific skills (component/feature/test scaffolding), and a code-review agent checklist.
- Introduces offline-first foundations (SharedPreferences cache + connectivity service) and offline repository wrappers for feed/marketplace/health, plus health utility helpers.
- Establishes baseline unit tests + testing documentation and adds a GitHub Actions workflow for analyze/test/build validation and migration filename checks.
Reviewed changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| test/models/user_model_test.dart | Adds UserModel unit tests (construction/JSON/copyWith roundtrip). |
| test/models/pet_model_test.dart | Adds PetModel unit tests (JSON parsing, defaults, copyWith, serialization expectations). |
| test/controllers/cart_controller_test.dart | Adds CartState unit tests for totals/copyWith/error clearing. |
| test/controllers/auth_notifier_test.dart | Adds AuthState unit tests (defaults/copyWith/enum sanity). |
| TEST_GUIDE.md | Documents how to run tests/coverage and testing best practices. |
| supabase/README.md | Documents Supabase directory structure and dev workflows. |
| supabase/MIGRATIONS.md | Adds detailed migration workflow and safety guidance. |
| supabase/config.toml | Adds Supabase CLI config for local development. |
| supabase/.gitignore | Ignores local Supabase env/secrets and temp files. |
| supabase/.env.local.example | Adds an env template for local Supabase variables. |
| OFFLINE_SUPPORT.md | Documents offline-first architecture, cache TTLs, and sync queue patterns. |
| lib/utils/safe_route_params.dart | Adds safe route param helpers + invalid-route error screen. |
| lib/utils/routes.dart | Uses safe route param extraction to avoid ! crashes on missing params. |
| lib/utils/offline_cache.dart | Implements SharedPreferences-backed cache + sync queue. |
| lib/utils/health_improvements.dart | Adds health tracking helper utilities (reminders, dose scheduling, metrics). |
| lib/utils/connectivity_service.dart | Adds a lightweight connectivity status service + stream. |
| lib/repositories/offline_marketplace_repository.dart | Offline wrapper for marketplace (product cache + queued orders). |
| lib/repositories/offline_health_repository.dart | Offline wrapper for health repository (cache + queued writes). |
| lib/repositories/offline_feed_repository.dart | Offline wrapper for feed (post caching + queued writes). |
| lib/repositories/feed_repository.dart | Fixes update payload construction to omit empty optional fields. |
| lib/repositories/auth_repository.dart | Makes profile creation failure fatal during signup with cleanup behavior. |
| lib/controllers/connectivity_controller.dart | Adds Riverpod providers for connectivity service and convenience flags. |
| IMPLEMENTATION_STATUS.md | Tracks Epic/issue implementation progress and testing status. |
| .github/workflows/test-and-build.yml | Adds CI workflow for analyze/tests/Android+iOS builds and migration name checks. |
| .claude/skills/test-writer/SKILL.md | Adds skill definition for generating tests. |
| .claude/skills/migration-helper/SKILL.md | Adds skill definition for scaffolding feature layers. |
| .claude/skills/flutter-new-component/SKILL.md | Adds skill definition for scaffolding reusable widgets. |
| .claude/settings.local.json | Expands local Claude permissions (git/tests/Supabase MCP operations). |
| .claude/settings.json | Adds hooks, protected paths, and MCP server registrations. |
| .claude/README.md | Documents Claude Code setup, skills, agents, and workflow recommendations. |
| .claude/agents/code-reviewer.md | Adds a detailed code-review checklist agent spec. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| uses: actions/setup-java@v3 | ||
| with: | ||
| distribution: 'temurin' | ||
| java-version: '11' |
| [db] | ||
| # Database connection pooling | ||
| port = 54322 | ||
| shadow_database_url = "postgresql://postgres:postgres@localhost:54323/postgres" |
Comment on lines
+2
to
+11
| # Copy this file to .env.local and fill in with your local Supabase credentials | ||
|
|
||
| # Local Supabase API URL (default: http://localhost:54321) | ||
| SUPABASE_URL=http://localhost:54321 | ||
|
|
||
| # Local Supabase Anon Key (default service role - use for development only!) | ||
| SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZvdWJva2NxYXh5cWdqaHRnenN4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzAxNDYwMjIsImV4cCI6MTk4NTcyMjAyMn0.EJ2yXR7-1sXcZqG8-QKh0z7m-ZYbWaI6lVPpNqnK-0s | ||
|
|
||
| # Local Supabase Service Role Key (for admin operations - keep secure!) | ||
| SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZvdWJva2NxYXh5cWdqaHRnenN4Iiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTY3MDE0NjAyMiwiZXhwIjoxOTg1NzIyMDIyfQ.DxfZ5Z2L-kJq0zB3e-p0Z0x0y0z0a0b0c0d0e0f0g0h0 |
Comment on lines
+55
to
+56
| // Note: We cache the model objects; they'll be JSON-serialized by saveJson | ||
| await _cache.cacheFeedPosts(posts); |
Comment on lines
+55
to
+57
| // Cache products (as JSON for storage) | ||
| await _cache.cacheProducts( | ||
| products.map((p) => p.toJson()).toList(), |
Comment on lines
+217
to
+221
| await _syncCreate(op); | ||
| case 'update': | ||
| await _syncUpdate(op); | ||
| case 'delete': | ||
| await _syncDelete(op); |
Comment on lines
+1
to
+8
| { | ||
| "hooks": [ | ||
| { | ||
| "trigger": "PostToolUse", | ||
| "tool": "Edit", | ||
| "description": "Auto-format and lint Dart files after editing", | ||
| "commands": ["dart format {filePath}", "flutter analyze --no-pub {filePath}"] | ||
| } |
Comment on lines
+5
to
+13
| "mcp__claude_ai_Supabase__list_tables", | ||
| "Bash(gh issue *)", | ||
| "Bash(flutter test *)", | ||
| "Bash(git add *)", | ||
| "Bash(git commit -m 'Implement Epic #58: Foundation & Release Blockers \\(build, routing, schema, tests\\) *)", | ||
| "mcp__plugin_supabase_supabase__list_projects", | ||
| "mcp__plugin_supabase_supabase__list_migrations", | ||
| "mcp__plugin_supabase_supabase__apply_migration", | ||
| "mcp__plugin_supabase_supabase__list_tables" |
Comment on lines
+19
to
+24
| /// Current connectivity status (watch this to rebuild on connectivity changes) | ||
| final connectivityStatusProvider = StreamProvider<ConnectivityStatus>((ref) { | ||
| final service = ref.watch(connectivityServiceProvider); | ||
| return service.statusStream.asBroadcastStream(); | ||
| }); | ||
|
|
Comment on lines
+37
to
48
| // Create the profile row — fatal if it fails to ensure user has a complete profile | ||
| try { | ||
| await supabase.from('profiles').upsert({ | ||
| 'id': user.id, | ||
| 'name': name, | ||
| }); | ||
| } catch (e) { | ||
| debugPrint('Profile upsert during signup failed (non-fatal): $e'); | ||
| // Clean up by signing out the user since profile creation failed | ||
| await supabase.auth.signOut(); | ||
| throw Exception( | ||
| 'Failed to create your profile. Please try signing up again. If the problem persists, contact support.'); | ||
| } |
This was referenced May 5, 2026
Add several Bash command patterns to .claude/settings.local.json to allow common git/GitHub CLI operations: Bash(gh pr *), Bash(gh run *), Bash(git restore *), Bash(git commit -m 'Fix: Update deprecated actions/upload-artifact from v3 to v4 *), and Bash(git push *). This expands the local Claude command whitelist for workflow and repo actions.
Add Stripe-based checkout and per-user cart persistence plus push-deeplink handling. Highlights: - Stripe: add flutter_stripe dependency, initialize publishable key in main, and switch Android activity to FlutterFragmentActivity to support Stripe PaymentSheet. - Server: add a Supabase Edge Function (create-payment-intent) to create Stripe PaymentIntents and a DB migration to add payment fields to orders (payment_provider, payment_intent_id, payment_status). - Marketplace repo: new CreatePaymentIntentResult, createStripePaymentIntent() to call the edge function, and payment-aware placeOrder() plus stock validation and out-of-stock errors. - Cart: CartController persists cart per authenticated user to SharedPreferences (debounced), loads/clears on auth changes, and integrates Stripe PaymentSheet into the checkout flow; CartItemModel and ProductModel gains JSON serialization helpers. - Push notifications: add push_deeplink_routes helper, wire notification-opened handler in PushNotificationCoordinator, and implement registerOnNotificationOpenedHandler in PushNotificationService to route users into the app on notification taps. - Build/config: update pubspec.yaml/lock for flutter_stripe, tweak android/gradle.properties for JDK/tooling and Kotlin incremental compile, and adjust Supabase CLI config and functions config for the new edge function. These changes enable on-device checkout with server-side PaymentIntent creation, persist carts across sessions per user, and deep-link users from notifications into the appropriate screens.
Manage realtime lifecycle and optimize follower queries, plus tighten Supabase debug fallback and update docs. - controllers/chat_controller.dart: added PetModel import; ensure realtime messages channel is unsubscribed and nulled on dispose and when active pet changes; listen to activePetProvider to load threads or reset ChatState, avoiding leaked channels and stale state. - controllers/feed_controller.dart: replace ad-hoc fetch/subscription logic with an authProvider listener that disposes/resubscribes like/comment channels on logout/login, triggers fetchPosts on user change, and returns a clean unauthenticated FeedState to prevent duplicate realtime subscriptions. - repositories/follow_repository.dart: use server-side count() for scalar follower/following counts; introduce fetchPetFollowerCounts to batch pet owner lookups and follower queries, deduplicate owner vs pet followers, and eliminate N+1/full-table scan patterns. - utils/supabase_config.dart: add SUPABASE_ALLOW_EMBEDDED_DEBUG_FALLBACK dart-define (default true) and fail fast in non-release builds when fallbacks are disabled, improving security hygiene; provide clearer error messages for missing env defines. - docs: update architecture and feature-practices docs with a May 7, 2026 implementation/status snapshot reflecting shipped fixes and remaining open items. These changes reduce realtime duplication/leaks, improve follower-count performance, and harden local/release Supabase configuration.
Switch Android app themes to Theme.MaterialComponents.DayNight.NoActionBar (values and values-night) so native UI (flutter_stripe PaymentSheet) works correctly; set windowBackground and navigationBarColor to use existing splash resources. Add com.google.android.material:material:1.12.0 to android/app/build.gradle.kts so Material attributes resolve. Also add docs/cursor_completed_issue_numbers_from_github.md (exported session notes) for bookkeeping.
Adds a large set of feature-focused controllers, data models, and repositories plus related view/route and pubspec updates. Key additions: - New controllers/providers: gear_reviews, knowledge_base, pet_breed (breed identifier + history), pet_events, pet_insurance, pet_memorial, pet_nutrition, pet_sitter, pet_training and related providers. - New models: GearReview, KnowledgeArticle, PetEvent, PetFriendlyPlace, PetMemorialEntry and others used by feature repos. - New repositories: adoption, community_group, and a consolidated feature_repositories (training, nutrition, gear reviews, memorials, etc.) backed by Supabase utilities. - HealthController enhancements: include upcomingAppointments in state, overdue appointment counting, and an idempotent 30-day medication dose generation flow (times/frequency helpers and repo call). Also triggers dose regeneration when medications change. - PetController updates: photo removal method (storage cleanup + DB clear) and a breed suggestions provider for autocomplete. - Added docs: remaining_issues_plan.md and analysis_results.txt. - Misc: multiple view files, routes, and package files updated to wire in new features. These changes implement many previously-mocked/stubbed features (events, groups, adoption, nutrition, training, gear reviews, memorials, breed ID) and improve health/medication handling and pet media management.
Revamp CI: simplify permissions, pin actions, update Java/Flutter versions, add formatting check, use Codecov token, rename jobs, add conditional Android/iOS builds, upload artifacts with new names, and add CodeQL security scan. App fixes/refactors: initialize OfflineCache in main; switch connectivity provider to a broadcast stream and update isOnline/isOffline providers; add missing toJson() implementations for PetModel and PostModel; small OFFLINE_SUPPORT fix (add breaks in switch); remove memorial gallery UI; simplify medication logic to count unique upcoming days and adjust overdue calculation; clarify auth_repository cleanup with comment/TODO about using an Edge Function to delete users; sanitize supabase .env example keys to placeholders.
Bump pinned GitHub Actions used in .github/workflows/test-and-build.yml to newer commits/releases for bug fixes and improvements. Updated actions/checkout (v4.1.1 -> v4.2.2), actions/setup-java (v3.13.0 -> v4.4.0), subosito/flutter-action (v2.12.0 -> v2.16.0), codecov/codecov-action (v3.1.4 -> v4.6.0), actions/upload-artifact (v4.1.0 -> v4.4.3), and github/codeql-action (init/analyze v3.25.3 -> v3.27.6). These are SHA-pinned updates in the workflow file; no functional workflow changes beyond the action upgrades are introduced.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a comprehensive Claude Code configuration for the PetSphere Flutter project, adding project-specific automation, code review, and code generation skills. It establishes a robust developer workflow with automated formatting, protected file permissions, and specialized tools for scaffolding features, components, and tests. The most important changes are summarized below:
Project Automation & Configuration
.claude/settings.jsonto configure automatic Dart formatting and linting hooks after file edits, define protected files to prevent accidental changes, and register MCP servers for Supabase database access and real-time Flutter/Dart documentation lookup..claude/settings.local.jsonto expand allowed permissions for local development, including running tests, managing git, and interacting with Supabase MCP plugins.Developer Skills & Scaffolding Tools
/flutter-new-componentskill to scaffold new Flutter components following PetSphere conventions, with options for stateless, stateful, and Riverpod consumer widgets./migration-helperskill to generate a complete feature layer (model, repository, controller) for new database-backed features, supporting options for images, timestamps, and user relationships./test-writerskill to generate unit tests for controllers, repositories, and utilities, following arrange-act-assert and Riverpod testing patterns.Code Review Automation
@code-reviewer) with a detailed checklist for Riverpod patterns, architecture compliance, null safety, repository pattern, error handling, and test readiness. Includes CI/CD integration instructions.Documentation & Workflow
.claude/README.mddocumenting all automation, skills, agents, hooks, workflow recommendations, troubleshooting, and file organization for the PetSphere project.These changes collectively establish a modern, automated, and best-practice-driven workflow for PetSphere Flutter development.